import React from 'react';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import HomePage from '../pages/HomePage';
import ArtworkDetailPage from '../pages/ArtworkDetailPage';
import ArtistProfilePage from '../pages/ArtistProfilePage';
import UploadPage from '../pages/UploadPage';
import AuthGuard from '../components/AuthGuard';

const AppRouter = () => {
  return (
    <BrowserRouter>
      <Routes>
        {/* 首页 */}
        <Route path="/" element={<HomePage />} />
        
        {/* 作品详情页 */}
        <Route path="/artwork/:id" element={<ArtworkDetailPage />} />
        
        {/* 艺术家主页 */}
        <Route path="/artist/:id" element={<ArtistProfilePage />} />
        
        {/* 需要登录的路由 */}
        <Route 
          path="/upload" 
          element={
            <AuthGuard>
              <UploadPage />
            </AuthGuard>
          } 
        />
        
        {/* 404重定向到首页 */}
        <Route path="*" element={<Navigate to="/" replace />} />
      </Routes>
    </BrowserRouter>
  );
};

export default AppRouter;